package Test04;

//异常作用1
public class Test03 {
    public static void main(String[] args) {
        /*
            异常作用一:异常是用来查询bug的关键参考信息
            异常作用二:异常可以作为方法内部的一种特殊返回值，以便通知调用者底层的执行情况
        */

        Student03 stu = new Student03("张三,23");

        System.out.println(stu);
    }
}

class Student03 {

    private String name;
    private int age;

    public Student03() {
    }

    public Student03(String str) {
        String[] arr = str.split("-");
        this.name = arr[0];
        this.age = Integer.parseInt(arr[1]);
    }

    public Student03(String name, int age) {
        this.name = name;
        this.age = age;
    }

    /**
     * 获取
     *
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     *
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     *
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    public String toString() {
        return "Student03{name = " + name + ", age = " + age + "}";
    }
}
